package com.zhengwl.study.nio;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

public class FileManager {

	public static String getPath() {
		Path path=Paths.get("D://test.log");
		try {
			try(BufferedWriter writer=Files.newBufferedWriter(path, StandardCharsets.UTF_8,StandardOpenOption.WRITE)){
				writer.write("hello,world");
			}
			try(BufferedReader reader=Files.newBufferedReader(path,StandardCharsets.UTF_8)) {
				String line;
				while ((line=reader.readLine())!=null) {
					System.out.println(line);
					
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		System.out.println(path.getFileName());
		System.out.println("path的根路径： "+path.getRoot());
		return "sss";
	}
}
